#ifndef _CANARY2_UTIL_ASSERT_H_
#define _CANARY2_UTIL_ASSERT_H_


#define WILSON_DEBUG




namespace wilson
{

[[noreturn]] void
report_assertion_failure(const char* expr, const char* file, long line, const char* msg) noexcept;

#define WILSON_UNREACHABLE() __builtin_unreachable()

#ifdef WILSON_DEBUG
#  define WILSON_XASSERT_FAIL_(...)     ::wilson::report_assertion_failure(__VA_ARGS__)
#else
#  define WILSON_XASSERT_FAIL_(...)     WILSON_UNREACHABLE()
#endif

#define WILSON_XASSERT_(cond, str, mt)  \
    ((cond) ? void(0) : WILSON_XASSERT_FAIL_(str, __FILE__, __LINE__, mt))

#define WILSON_ASSERT(expr)             WILSON_XASSERT_(expr, #expr, "")
#define WILSON_ASSERT_MSG(expr, mt)     WILSON_XASSERT_(expr, #expr, mt)

}


#endif
